import os
import path
from gxl_ai_utils.utils import utils_file


def get_scp_file(source_path: str = '/home/work_nfs6/lhma/wash_data/sample1000/res/muise_denoise',
                 output_scp_file: str = './output/wav.scp'):
    utils_file.makedir_for_file(output_scp_file)
    for root, dirs, files in os.walk(source_path):
        res_dic = {}
        for file in files:
            if file.endswith('.wav') or file.endswith('.WAV'):
                if len(file.strip().split('_')) >= 2:
                    key = file.strip().split('_')[0] + "_" + file.strip().split('_')[1]
                else:
                    key = file.strip().split('.')[0]
                wav_path = os.path.join(root, file)
                res_dic[key] = wav_path
        utils_file.write_dic_to_scp(res_dic, output_scp_file)
        break


if __name__ == '__main__':
    """"""
    little_aishell_path = 'E:\gengxuelong_study\server_local_adapter\\ai\data\small_aishell\dev'
    get_scp_file(little_aishell_path)
